package analysis

import (
	"ginfwk/infrastructure/helper/ghttp"
	"github.com/gin-gonic/gin"
)

type Analysis struct {
}

// Total 用户来源
// url:/admin/analysis/total
func (u *Analysis) Total(g *gin.Context) interface{} {
	type AnalysisTotal struct {
		Users     int `json:"users"`
		Messages  int `json:"messages"`
		Moneys    int `json:"moneys"`
		Shoppings int `json:"shoppings"`
	}

	res := AnalysisTotal{
		Users:     102400,
		Messages:  81212,
		Moneys:    9280,
		Shoppings: 13600,
	}
	return ghttp.Success(res)
}

// UserAccessSource 用户来源
// url:/admin/analysis/userAccessSource
func (u *Analysis) UserAccessSource(g *gin.Context) interface{} {
	type AnalysisItem struct {
		Value int    `json:"value"`
		Name  string `json:"name"`
	}

	res := []AnalysisItem{
		{Value: 1000, Name: "analysis.directAccess"},
		{Value: 310, Name: "analysis.mailMarketing"},
		{Value: 234, Name: "analysis.allianceAdvertising"},
		{Value: 135, Name: "analysis.videoAdvertising"},
		{Value: 1548, Name: "analysis.searchEngines"},
	}
	return ghttp.Success(res)
}

// WeeklyUserActivity 每周用户活跃量
// url:/admin/analysis/weeklyUserActivity
func (u *Analysis) WeeklyUserActivity(g *gin.Context) interface{} {
	type AnalysisItem struct {
		Value int    `json:"value"`
		Name  string `json:"name"`
	}

	res := []AnalysisItem{
		{Value: 13253, Name: "analysis.monday"},
		{Value: 34235, Name: "analysis.tuesday"},
		{Value: 26321, Name: "analysis.wednesday"},
		{Value: 12340, Name: "analysis.thursday"},
		{Value: 24643, Name: "analysis.friday"},
		{Value: 1322, Name: "analysis.saturday"},
		{Value: 1324, Name: "analysis.sunday"},
	}
	return ghttp.Success(res)
}

// MonthlySales 每月销售额
// url:/admin/analysis/monthlySales
func (u *Analysis) MonthlySales(g *gin.Context) interface{} {
	type AnalysisItem struct {
		Estimate int    `json:"estimate"`
		Actual   int    `json:"actual"`
		Name     string `json:"name"`
	}

	res := []AnalysisItem{
		{Estimate: 100, Actual: 120, Name: "analysis.january"},
		{Estimate: 120, Actual: 82, Name: "analysis.february"},
		{Estimate: 161, Actual: 91, Name: "analysis.march"},
		{Estimate: 134, Actual: 154, Name: "analysis.april"},
		{Estimate: 105, Actual: 162, Name: "analysis.may"},
		{Estimate: 160, Actual: 140, Name: "analysis.june"},
		{Estimate: 165, Actual: 145, Name: "analysis.july"},
		{Estimate: 114, Actual: 250, Name: "analysis.august"},
		{Estimate: 163, Actual: 134, Name: "analysis.september"},
		{Estimate: 185, Actual: 56, Name: "analysis.october"},
		{Estimate: 118, Actual: 99, Name: "analysis.november"},
		{Estimate: 123, Actual: 123, Name: "analysis.december"},
	}
	return ghttp.Success(res)
}
